﻿using AutoMapper;
using B.S.Base.ErrorCode;
using B.S.Base.Moain.Entities;
using B.S.Base.Read.Api.Application.Command.Products;
using B.S.Base.Read.Api.Application.Command.Shops;
using B.S.Base.Read.Api.Dto;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Base.Read.Api.Controllers
{
    /// <summary>
    /// Api控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManyController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<ManyController> logger;

        public ManyController(IMediator mediator, ILogger<ManyController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 获取商品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public Task<APIPaging<ProductDTO>> GetProduct([FromQuery] ShowProductCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取商品名称
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public Task<APIResult<List<Shop>>> GetShop([FromQuery]ShowShopCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }
    }
}
